/*
 * Universidade Estadual de Campinas - UNICAMP
 * MC823 - Laboratório de Redes
 * Alunos:
 *         Daniel Camillo C. Farias  RA: 059878
 *         Vitor Hugo Mickus Rodrigues RA: 072627
 * Professor:
 *         Paulo Lício e Celio
 *
 * Server program for Network Labs. Simulate an ECHO program.
 *
 */

// Default includes for server
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

#define CONNECT
#define MYPORT 3490 /*the port users will be connecting to*/
#define MAXBUFLEN 300
#define ALARM_TIMEOUT 10

#ifdef CONNECT

#define _CONNECT(sockfd, addr, addrlen) \
  connect(sockfd,addr,addrlen);
#define _SEND_TO_CLIENT(sockfd, send_buf, buflen, destaddr, addrlen) \
  send(sockfd, send_buf, buflen, 0)
#define _RECV_FROM_CLIENT(sockfd, receive_buf, max_buflen, srcaddr, addrlen) \
  recv(sockfd, receive_buf, max_buflen, 0)

#else

#define _CONNECT(sockfd, addr, addrlen)
#define _SEND_TO_CLIENT(sockfd, send_buf, buflen, destaddr, addrlen) \
  sendto(sockfd, send_buf, buflen, 0, destaddr, addrlen)
      
#define _RECV_FROM_CLIENT(sockfd, receive_buf, max_buflen, srcaddr, addrlen) \
  recvfrom(sockfd, receive_buf, max_buflen, 0, srcaddr, addrlen)

#endif

